home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d17 / labels.arc / LABALIGN.C next >
C/C++ Source or Header  |  1988-05-12  |  2KB  |  89 lines

  1. /* ALIGN LABEL - A Program to Align Mailing Labels */
  2. /* Version 1.0 by Richard Conn */
  3.  
  4. /* Usage: labalign [-L#] [-C#] [-B#] [-N#] */
  5.  
  6. /* Instructions:
  7.    This program outputs a series of alignment labels to
  8.    help the user align the mailing labels in his printer.
  9.  
  10.    Available options are:
  11.        -L# - set the number of text lines per label (default 8)
  12.        -C# - set the number of columns per label (default 40)
  13.        -B# - set the number of blank lines between labels (default 1)
  14.        -N# - set the number of labels to print (default 5)
  15. */
  16.  
  17. #include <stdio.h>
  18.  
  19. #define NLINES 8
  20. #define NCOLS 40
  21. #define NBLANKS 1
  22. #define NLABS 5
  23.  
  24. int lines = NLINES;
  25. int columns = NCOLS;
  26. int blanks = NBLANKS;
  27. int labs = NLABS;
  28.  
  29. main (argc, argv)
  30. int argc;
  31. char *argv[];
  32. {
  33.         int i;
  34.         int opterr = 0;
  35.  
  36.     for (i=1; i<argc; i++) {
  37.         if (*argv[i] == '-') {
  38.             switch (argv[i][1]) {
  39.                 case 'b' :
  40.                 case 'B' : blanks = atoi (&argv[i][2]);
  41.                        if (blanks == 0) opterr = 1;
  42.                        break;
  43.                 case 'c' :
  44.                 case 'C' : columns = atoi (&argv[i][2]);
  45.                        if (columns == 0) opterr = 1;
  46.                        break;
  47.                 case 'l' :
  48.                 case 'L' : lines = atoi (&argv[i][2]);
  49.                        if (lines == 0) opterr = 1;
  50.                        break;
  51.                 case 'n' :
  52.                 case 'N' : labs = atoi (&argv[i][2]);
  53.                        if (labs == 0) opterr = 1;
  54.                        break;
  55.                 default  : opterr = 1;
  56.                        break;
  57.             }
  58.         }
  59.     }
  60.     if (opterr) {
  61.         printf (" Syntax: %s [-L#] [-C#] [-B#] [-N#]\n", argv[0]);
  62.         printf ("   Where:\n");
  63.         printf ("     -L# is the number of text lines/label (def %d)\n",
  64.             NLINES);
  65.         printf ("     -C# is the number of columns/label (def %d)\n",
  66.             NCOLS);
  67.         printf ("     -B# is the number of blank lines between labels (def %d)\n",
  68.             NBLANKS);
  69.         printf ("     -N# is the number of labels to print (def %d)\n",
  70.             NLABS);
  71.     } else align();
  72. }
  73.  
  74. /* Print an alignment series */
  75. align ()
  76. {
  77.     int i, j, k;
  78.  
  79.     for (k=0; k<labs; k++) {
  80.         for (i=0; i<lines; i++) {
  81.             for (j=0; j<columns; j++)
  82.                 if (j % 5) printf ("-");
  83.                 else printf ("|");
  84.             printf ("\n");
  85.         }
  86.         for (j=0; j<blanks; j++) printf ("\n");
  87.     }
  88. }
  89.